﻿package com.tudou.home.model
{
    import com.tudou.home.commands.*;
    import com.tudou.home.model.data.*;
    import org.puremvc.as3.patterns.proxy.*;

    public class PlayListSingleProxy extends Proxy implements IProxy
    {
        private var playList:Array;
        private var pageInfo:PageInfo;
        private var playIndex:uint = 0;
        public static const NAME:String = "PlayListSingleProxy";

        public function PlayListSingleProxy()
        {
            super(NAME);
            pageInfo = PageInfo.getInstance();
            return;
        }// end function

        public function nextItem() : void
        {
            thisIndex((playIndex + 1));
            return;
        }// end function

        public function getPlayList() : Array
        {
            return playList;
        }// end function

        public function setRelativeList(param1:Object) : void
        {
            var _loc_3:Object = null;
            var _loc_4:BaseVideoInfo = null;
            var _loc_2:* = param1 as Array;
            playList = [];
            var _loc_5:int = 0;
            var _loc_6:* = _loc_2.length;
            if (_loc_2.length <= 0)
            {
                return;
            }
            _loc_5 = 0;
            while (_loc_5 < _loc_6)
            {
                
                _loc_3 = _loc_2[_loc_5] as BaseVideoInfo;
                playList[_loc_5] = _loc_3;
                _loc_5++;
            }
            return;
        }// end function

        public function prevItem() : void
        {
            thisIndex((playIndex - 1));
            return;
        }// end function

        public function thisIndex(param1:uint) : void
        {
            if (param1 >= playList.length)
            {
                param1 = 0;
            }
            playIndex = param1;
            var _loc_2:* = playList[playIndex] as BaseVideoInfo;
            sendNotification(PlayListSingleCommandSet.CHANGE_ITEM, _loc_2);
            return;
        }// end function

        public function get showTransFinished() : Boolean
        {
            return playIndex < (playList.length - 1) ? (true) : (false);
        }// end function

        public function getIndex() : uint
        {
            return playIndex;
        }// end function

    }
}
